let api = [];
const apiDocListSize = 1
api.push({
    name: 'default',
    order: '1',
    list: []
})
api[0].list.push({
    alias: '29fec6280b774b7a7a1981360315cf61',
    order: '1',
    link: '',
    desc: '',
    list: []
})
api[0].list[0].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/device/findAllDeviceInfo',
    desc: '',
});
api[0].list[0].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/device/setDeviceInfo',
    desc: '',
});
api[0].list.push({
    alias: '942b9fbcf224712e2eb24bace17cbb96',
    order: '2',
    link: '',
    desc: '',
    list: []
})
api[0].list[1].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/deviceList',
    desc: '硬件调试-展示所有设备信息',
});
api[0].list[1].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/deviceStepList',
    desc: '硬件调试-查询所有流程相关步数',
});
api[0].list[1].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/deviceEditStepParam',
    desc: '',
});
api[0].list[1].list.push({
    order: '4',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/processStart',
    desc: '流程开启',
});
api[0].list[1].list.push({
    order: '5',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/hcMotorStop',
    desc: '汇川电机-电机停止',
});
api[0].list[1].list.push({
    order: '6',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/hcMotorReady',
    desc: '汇川电机-电机使能',
});
api[0].list[1].list.push({
    order: '7',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/hcMotorHoming',
    desc: '汇川电机-电机回原点',
});
api[0].list[1].list.push({
    order: '8',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/hcMotorRun',
    desc: '汇川电机-电机运动',
});
api[0].list[1].list.push({
    order: '9',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/bkMotorStop',
    desc: '步科电机-电机停止',
});
api[0].list[1].list.push({
    order: '10',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/bkMotorRun',
    desc: '步科电机-电机停止',
});
api[0].list[1].list.push({
    order: '11',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/lsMotorBack',
    desc: '雷赛电机 回零',
});
api[0].list[1].list.push({
    order: '12',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/lsMotorEmergencyStop',
    desc: '雷赛电机 急停',
});
api[0].list[1].list.push({
    order: '13',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/smartWriteIO',
    desc: '',
});
api[0].list[1].list.push({
    order: '14',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/borunteRobotSetAxisZ',
    desc: '机器人流程 - 设置Z轴高度',
});
api[0].list[1].list.push({
    order: '15',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/borunteRobotSetAxisUVW',
    desc: '机器人流程 - 设置UVW轴高度',
});
api[0].list[1].list.push({
    order: '16',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/borunteRobotInitLocation',
    desc: '机器人流程 - 初始化位置',
});
api[0].list[1].list.push({
    order: '17',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/borunteRobotPickLocation',
    desc: '机器人流程 - 抓料点位置',
});
api[0].list[1].list.push({
    order: '18',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/borunteRobotSendM00',
    desc: '机器人流程 - 信号交互',
});
api[0].list[1].list.push({
    order: '19',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/hardwareDebug/borunteRobotPause',
    desc: '机器人流程 - 暂停与启动',
});
api[0].list.push({
    alias: '3b739b1e9e914cd25776d1c68fba0d37',
    order: '3',
    link: '',
    desc: '',
    list: []
})
api[0].list[2].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/regular',
    desc: '移动固定托盘',
});
api[0].list[2].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/photograph',
    desc: '移动到拍照位',
});
api[0].list[2].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/bore',
    desc: '',
});
api[0].list[2].list.push({
    order: '4',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/cameraResult',
    desc: '',
});
api[0].list[2].list.push({
    order: '5',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/runY',
    desc: '',
});
api[0].list[2].list.push({
    order: '6',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/start',
    desc: '',
});
api[0].list[2].list.push({
    order: '7',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/axisControl',
    desc: '',
});
api[0].list[2].list.push({
    order: '8',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/robot',
    desc: '',
});
api[0].list[2].list.push({
    order: '9',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/writeMotorValue',
    desc: '',
});
api[0].list[2].list.push({
    order: '10',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/testDown',
    desc: '',
});
api[0].list[2].list.push({
    order: '11',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/testUp',
    desc: '',
});
api[0].list[2].list.push({
    order: '12',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/testPress',
    desc: '',
});
api[0].list[2].list.push({
    order: '13',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/stopPress',
    desc: '',
});
api[0].list[2].list.push({
    order: '14',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/testUpStop',
    desc: '',
});
api[0].list[2].list.push({
    order: '15',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/testDownStop',
    desc: '',
});
api[0].list[2].list.push({
    order: '16',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/controlPlcDORun',
    desc: '',
});
api[0].list[2].list.push({
    order: '17',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/controlInspireMotorRun',
    desc: '因时 串口 7  micro 串口 3',
});
api[0].list[2].list.push({
    order: '18',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBoltRobot/controlMicroMotorRun',
    desc: '',
});
api[0].list.push({
    alias: 'f961c84362a75b2a8e675c5cac8134b5',
    order: '4',
    link: '',
    desc: '',
    list: []
})
api[0].list[3].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBolt/writeValue',
    desc: '',
});
api[0].list[3].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBolt/writeStartValue',
    desc: '',
});
api[0].list[3].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/assemblyBolt/sse/{id}',
    desc: '首页数据请求',
});
api[0].list.push({
    alias: '43e61275862f5c3dfa5f55fea30e1063',
    order: '5',
    link: '接口文档测试',
    desc: '接口文档测试',
    list: []
})
api[0].list[4].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/send',
    desc: '测试提交校验',
});
api[0].list[4].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/save',
    desc: '保存',
});
api[0].list[4].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/saveDesc',
    desc: '测试保存关联表数据',
});
api[0].list[4].list.push({
    order: '4',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/list',
    desc: '查询列表',
});
api[0].list[4].list.push({
    order: '5',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/page',
    desc: '多条件查询',
});
api[0].list[4].list.push({
    order: '6',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/query',
    desc: '测试 querydsl 查询',
});
api[0].list[4].list.push({
    order: '7',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/queryPage',
    desc: '测试 querydsl 查询',
});
api[0].list[4].list.push({
    order: '8',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/api/demo/sendWs',
    desc: '',
});
api[0].list.push({
    alias: '84d36e9ae3a8d4c7493a32222c7b65a2',
    order: '6',
    link: '',
    desc: '',
    list: []
})
api[0].list[5].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/optRecords/get/optRecords/page/data/{pageSize}/{pageNumber}',
    desc: '',
});
api[0].list.push({
    alias: 'bb43abecc4829a7fb0b864f34c7f6573',
    order: '7',
    link: '',
    desc: '',
    list: []
})
api[0].list[6].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/punctureCable/robotPickAction',
    desc: '机器人抓料单点',
});
api[0].list[6].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/punctureCable/sse/{id}',
    desc: '首页数据请求',
});
api[0].list[6].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/punctureCable/testRun1',
    desc: '',
});
api[0].list[6].list.push({
    order: '4',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/punctureCable/testRun2',
    desc: '',
});
api[0].list[6].list.push({
    order: '5',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/punctureCable/robotPickRun',
    desc: '机器人抓料流程',
});
api[0].list[6].list.push({
    order: '6',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/punctureCable/test',
    desc: '',
});
api[0].list.push({
    alias: 'dafe6da9d42621b11e642ff5e19edbf6',
    order: '8',
    link: '',
    desc: '',
    list: []
})
api[0].list[7].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/spacerControl/saveParameters',
    desc: '',
});
api[0].list[7].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/spacerControl/saveStaticParameters',
    desc: '',
});
api[0].list[7].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/spacerControl/controlSwitch',
    desc: '',
});
api[0].list[7].list.push({
    order: '4',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/spacerControl/motorAbsRun',
    desc: '',
});
api[0].list[7].list.push({
    order: '5',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/spacerControl/motorJogRun',
    desc: '',
});
api[0].list[7].list.push({
    order: '6',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/spacerControl/motorRelativeRun',
    desc: '',
});
api[0].list.push({
    alias: '9879a643a86cb3d98bf0a3fde8e0f6fc',
    order: '9',
    link: '',
    desc: '',
    list: []
})
api[0].list[8].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/OrderNumberInput',
    desc: '',
});
api[0].list[8].list.push({
    order: '2',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/OrderNumberGenerate',
    desc: '',
});
api[0].list[8].list.push({
    order: '3',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/setMesParam',
    desc: '接收 Mes工单号-电站名称-间隔号',
});
api[0].list[8].list.push({
    order: '4',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/motorProcess',
    desc: '电机流程开始',
});
api[0].list[8].list.push({
    order: '5',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/motorManual',
    desc: '手动控制电机',
});
api[0].list[8].list.push({
    order: '6',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/motorJogRun',
    desc: '',
});
api[0].list[8].list.push({
    order: '7',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/motorResetting',
    desc: '测试',
});
api[0].list[8].list.push({
    order: '8',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/paramSetting',
    desc: '修改参数',
});
api[0].list[8].list.push({
    order: '9',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findAllParam',
    desc: '查数据库_字典型号',
});
api[0].list[8].list.push({
    order: '10',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findAllEvent',
    desc: '查数据库_事件所有内容',
});
api[0].list[8].list.push({
    order: '11',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/calibrationRun',
    desc: '',
});
api[0].list[8].list.push({
    order: '12',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/calibrationGet',
    desc: '',
});
api[0].list[8].list.push({
    order: '13',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findAllRecords',
    desc: '',
});
api[0].list[8].list.push({
    order: '14',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findEventById',
    desc: '查数据库_事件通过事件Id查询',
});
api[0].list[8].list.push({
    order: '15',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findSSeDate',
    desc: '',
});
api[0].list[8].list.push({
    order: '16',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findSSeDataResult',
    desc: '',
});
api[0].list[8].list.push({
    order: '17',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findSSeDataList',
    desc: '',
});
api[0].list[8].list.push({
    order: '18',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findSSeDataList1',
    desc: '',
});
api[0].list[8].list.push({
    order: '19',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/findEventByTime',
    desc: '通过型号Id和时间进行查询',
});
api[0].list[8].list.push({
    order: '20',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/sse/{id}',
    desc: '首页数据请求',
});
api[0].list[8].list.push({
    order: '21',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/selfCheck',
    desc: '',
});
api[0].list[8].list.push({
    order: '22',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/nowWarnRest',
    desc: '',
});
api[0].list[8].list.push({
    order: '23',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/lastWarnRest',
    desc: '',
});
api[0].list[8].list.push({
    order: '24',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/homeInfo',
    desc: '',
});
api[0].list[8].list.push({
    order: '25',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/lsMotorBack',
    desc: '雷赛电机 回零',
});
api[0].list[8].list.push({
    order: '26',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/lsMotorEmergencyStop',
    desc: '雷赛电机 急停',
});
api[0].list[8].list.push({
    order: '27',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/wallPulley/faultInfo',
    desc: '查数据库_事件所有内容',
});
api[0].list.push({
    alias: 'a412a0c5e60e9177e8e0ec489384e0c3',
    order: '10',
    link: '',
    desc: '',
    list: []
})
api[0].list[9].list.push({
    order: '1',
    deprecated: 'false',
    url: 'http://127.0.0.1:8080/custom/push/{clientId}',
    desc: '',
});
api[0].list.push({
    alias: 'error',
    order: '11',
    link: 'error_code_list',
    desc: '错误码列表',
    list: []
})
document.onkeydown = keyDownSearch;
function keyDownSearch(e) {
    const theEvent = e;
    const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
    if (code === 13) {
        const search = document.getElementById('search');
        const searchValue = search.value.toLocaleLowerCase();

        let searchGroup = [];
        for (let i = 0; i < api.length; i++) {

            let apiGroup = api[i];

            let searchArr = [];
            for (let i = 0; i < apiGroup.list.length; i++) {
                let apiData = apiGroup.list[i];
                const desc = apiData.desc;
                if (desc.toLocaleLowerCase().indexOf(searchValue) > -1) {
                    searchArr.push({
                        order: apiData.order,
                        desc: apiData.desc,
                        link: apiData.link,
                        list: apiData.list
                    });
                } else {
                    let methodList = apiData.list || [];
                    let methodListTemp = [];
                    for (let j = 0; j < methodList.length; j++) {
                        const methodData = methodList[j];
                        const methodDesc = methodData.desc;
                        if (methodDesc.toLocaleLowerCase().indexOf(searchValue) > -1) {
                            methodListTemp.push(methodData);
                            break;
                        }
                    }
                    if (methodListTemp.length > 0) {
                        const data = {
                            order: apiData.order,
                            desc: apiData.desc,
                            link: apiData.link,
                            list: methodListTemp
                        };
                        searchArr.push(data);
                    }
                }
            }
            if (apiGroup.name.toLocaleLowerCase().indexOf(searchValue) > -1) {
                searchGroup.push({
                    name: apiGroup.name,
                    order: apiGroup.order,
                    list: searchArr
                });
                continue;
            }
            if (searchArr.length === 0) {
                continue;
            }
            searchGroup.push({
                name: apiGroup.name,
                order: apiGroup.order,
                list: searchArr
            });
        }
        let html;
        if (searchValue === '') {
            const liClass = "";
            const display = "display: none";
            html = buildAccordion(api,liClass,display);
            document.getElementById('accordion').innerHTML = html;
        } else {
            const liClass = "open";
            const display = "display: block";
            html = buildAccordion(searchGroup,liClass,display);
            document.getElementById('accordion').innerHTML = html;
        }
        const Accordion = function (el, multiple) {
            this.el = el || {};
            this.multiple = multiple || false;
            const links = this.el.find('.dd');
            links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown);
        };
        Accordion.prototype.dropdown = function (e) {
            const $el = e.data.el;
            let $this = $(this), $next = $this.next();
            $next.slideToggle();
            $this.parent().toggleClass('open');
            if (!e.data.multiple) {
                $el.find('.submenu').not($next).slideUp("20").parent().removeClass('open');
            }
        };
        new Accordion($('#accordion'), false);
    }
}

function buildAccordion(apiGroups, liClass, display) {
    let html = "";
    if (apiGroups.length > 0) {
        if (apiDocListSize === 1) {
            let apiData = apiGroups[0].list;
            let order = apiGroups[0].order;
            for (let j = 0; j < apiData.length; j++) {
                html += '<li class="'+liClass+'">';
                html += '<a class="dd" href="#_'+order+'_'+apiData[j].order+'_' + apiData[j].link + '">' + apiData[j].order + '.&nbsp;' + apiData[j].desc + '</a>';
                html += '<ul class="sectlevel2" style="'+display+'">';
                let doc = apiData[j].list;
                for (let m = 0; m < doc.length; m++) {
                    let spanString;
                    if (doc[m].deprecated === 'true') {
                        spanString='<span class="line-through">';
                    } else {
                        spanString='<span>';
                    }
                    html += '<li><a href="#_'+order+'_' + apiData[j].order + '_' + doc[m].order + '_' + doc[m].desc + '">' + apiData[j].order + '.' + doc[m].order + '.&nbsp;' + spanString + doc[m].desc + '<span></a> </li>';
                }
                html += '</ul>';
                html += '</li>';
            }
        } else {
            for (let i = 0; i < apiGroups.length; i++) {
                let apiGroup = apiGroups[i];
                html += '<li class="'+liClass+'">';
                html += '<a class="dd" href="#_'+apiGroup.order+'_' + apiGroup.name + '">' + apiGroup.order + '.&nbsp;' + apiGroup.name + '</a>';
                html += '<ul class="sectlevel1">';

                let apiData = apiGroup.list;
                for (let j = 0; j < apiData.length; j++) {
                    html += '<li class="'+liClass+'">';
                    html += '<a class="dd" href="#_'+apiGroup.order+'_'+ apiData[j].order + '_'+ apiData[j].link + '">' +apiGroup.order+'.'+ apiData[j].order + '.&nbsp;' + apiData[j].desc + '</a>';
                    html += '<ul class="sectlevel2" style="'+display+'">';
                    let doc = apiData[j].list;
                    for (let m = 0; m < doc.length; m++) {
                       let spanString;
                       if (doc[m].deprecated === 'true') {
                           spanString='<span class="line-through">';
                       } else {
                           spanString='<span>';
                       }
                       html += '<li><a href="#_'+apiGroup.order+'_' + apiData[j].order + '_' + doc[m].order + '_' + doc[m].desc + '">'+apiGroup.order+'.' + apiData[j].order + '.' + doc[m].order + '.&nbsp;' + spanString + doc[m].desc + '<span></a> </li>';
                   }
                    html += '</ul>';
                    html += '</li>';
                }

                html += '</ul>';
                html += '</li>';
            }
        }
    }
    return html;
}